<?php

class Application_Form_Clientes extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
    	$this->setAttrib('id', 'frmClientes')
    		 ->setMethod('post')
    		 ->setAction('/clientes/edit/');
    	
    	$this->addElement('hidden', 'id_clientes');
    	
    	$this->addElement('text', 'nombre', array(
            'label'      => 'Nombre:',
            'required'   => true,
            'filters'    => array('StringTrim'),
    		'size'		 => 60            
        ));
        
        $this->addElement('text', 'apellidos', array(
            'label'      => 'Apellidos:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 60             
        ));
        
        $this->addElement('text', 'nif', array(
            'label'      => 'NIF:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 20             
        ));
        
        $this->addElement('text', 'direccion', array(
            'label'      => 'Direccion:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 60
        ));
        
        $this->addElement('text', 'dire_num', array(
            'label'      => 'Num.:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 17            
        ));
        
        $this->addElement('text', 'dire_piso', array(
            'label'      => 'Piso:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 17            
        ));
    	
        $this->addElement('text', 'dire_puerta', array(
            'label'      => 'Puerta:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 17            
        ));
        
        $this->addElement('text', 'dire_cp', array(
            'label'      => 'C.P.:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 15           
        ));
        
        $this->addElement('text', 'poblacion', array(
            'label'      => 'Poblacion:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 40            
        ));
        
        $this->addElement('text', 'provincia', array(
            'label'      => 'Provincia:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 30            
        ));
        
        $this->addElement('text', 'pais', array(
            'label'      => 'Pais:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 30            
        ));
        
        $this->addElement('text', 'telefono', array(
            'label'      => 'Telefono:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 20             
        ));
        
        $this->addElement('text', 'telefono2', array(
            'label'      => 'Movil:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 20             
        ));
        
        $this->addElement('text', 'fax', array(
            'label'      => 'Fax:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 20 
        ));
        
        $this->addElement('text', 'mail', array(
            'label'      => 'E-Mail:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 50
        ));
        
        $this->addElement('text', 'cod_tipo_clie', array(
            'label'      => 'Tipo:',
            'required'   => true,
            'filters'    => array('StringTrim'),
        	'size'		 => 20
        ));
        
        $this->addElement('text', 'empresa', array(
            'label'      => 'Empresa:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 20             
        ));
        
        $this->addElement('text', 'url', array(
            'label'      => 'Web:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 50
        ));
        
        $this->addElement('text', 'descuento', array(
            'label'      => 'Descuento:',
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'size'		 => 20 
        ));
        
        $this->addElement('checkbox', 'activo', array(
            'label'      => 'Activo:',
            'required'   => false,
        ));
        
        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Guardar y cerrar',
        ));
        
        $this->addElement('button', 'eliminar', array(
            'ignore'   => true,
            'label'    => 'Eliminar',
        ));
        
        $this->addElement('hidden', 'error_form', array(
            'required'   => false,
            'filters'    => array('StringTrim'),
        	'value'		 => 0,	
        	'size'		 => 20 
        ));
    }

    public function muestraErrores($array)
    {
    	$valores = array();
    	foreach ($array as $key => $value) {
    		foreach ($array[$key] as $value2) {
    			$valores[] = $key. " ". $value2;	
    		}
    	}
    	return $valores;
    }

}

